﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using PS.DBUtility;
using System.Web.UI;
using System.Collections.Generic;
namespace PS.DAL
{
    /// <summary>
    /// 数据访问类:ExamSysPara
    /// </summary>
    public partial class ExamSysPara
    {
        public ExamSysPara()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ExamSysParaID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from ExamSysPara");
            strSql.Append(" where ExamSysParaID=@ExamSysParaID");
            SqlParameter[] parameters = {
					new SqlParameter("@ExamSysParaID", SqlDbType.Int,4)
};
            parameters[0].Value = ExamSysParaID;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 检查考试参数是否已经被使用
        /// </summary>
        /// <param name="ExamSysParaID"></param>
        /// <returns></returns>
        public bool ExistsExamRecords(int ExamSysParaID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from ExamRecord");
            strSql.Append(" where ExamSysParaID=@ExamSysParaID and validmark=1");
            SqlParameter[] parameters = {
					new SqlParameter("@ExamSysParaID", SqlDbType.Int,4)
};
            parameters[0].Value = ExamSysParaID;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 新增加一条参数
        /// </summary>
        /// <param name="CurrentPage">当前页</param>
        /// <param name="CurrentUser">当前用户</param>
        /// <returns>正确添加返回1，失败返回0</returns>
        public int AddSysPara(Page CurrentPage, string CurrentUser)
        {
            int InsertCount = 0;
            int Result = 0;

            string Spare1 = (CurrentPage.Request["ExamName"] != null && CurrentPage.Request["ExamName"].ToString().Length > 0) ? CurrentPage.Request["ExamName"].ToString().Trim() : "";

            int? ExamTimes = (CurrentPage.Request["ExamTimes"] != null && CurrentPage.Request["ExamTimes"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamTimes"].ToString()) : 0;
            int? ExamTime = (CurrentPage.Request["ExamTime"] != null && CurrentPage.Request["ExamTime"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamTime"].ToString()) : 0;
            string ExamDescription = (CurrentPage.Request["ExamDescription"] != null && CurrentPage.Request["ExamDescription"].ToString().Length > 0) ? CurrentPage.Request["ExamDescription"].ToString() : "";
            int QuestionsTotal = (CurrentPage.Request["QuestionsTotal"] != null && CurrentPage.Request["QuestionsTotal"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionsTotal"].ToString()) : 0;
            string Creator = CurrentUser;

            DateTime? CreateTime = System.DateTime.Now;
            decimal SumScore = (CurrentPage.Request["SumScore"] != null && CurrentPage.Request["SumScore"].ToString().Length > 0) ? decimal.Parse(CurrentPage.Request["SumScore"].ToString()) : 0;
            int? ExamType = (CurrentPage.Request["ExamType"] != null && CurrentPage.Request["ExamType"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamType"].ToString()) : 0;
            DateTime? ExamStartDate = DateTime.Parse(CurrentPage.Request["ExamStartDate"].ToString());
            DateTime? ExamFinishDate = DateTime.Parse(CurrentPage.Request["ExamFinishDate"].ToString());

            Model.ExamSysPara ExamParaMode = new PS.Model.ExamSysPara();
            ExamParaMode.ExamTimes = ExamTimes;
            ExamParaMode.ExamTime = ExamTime;
            ExamParaMode.ExamDescription = ExamDescription;
            ExamParaMode.QuestionsTotal = QuestionsTotal;
            ExamParaMode.Creator = Creator;
            ExamParaMode.CreateTime = CreateTime;
            ExamParaMode.SumScore = SumScore;
            ExamParaMode.ExamType = ExamType;
            ExamParaMode.ExamStartDate = ExamStartDate;
            ExamParaMode.ExamFinishDate = ExamFinishDate;
            ExamParaMode.Spare1 = Spare1;

            DAL.ExamSysPara ExamPara = new PS.DAL.ExamSysPara();
            int ExamSysParaID = ExamPara.Add(ExamParaMode);
            if (ExamSysParaID > 0) InsertCount++;
            Model.ExamQuestionType ExamQuesTypeMode = new PS.Model.ExamQuestionType();
            int QuestionType1 = 0;
            int? QuestionCount1 = 0;
            decimal? SingleQuestionScore1 = 0;

            QuestionType1 = (CurrentPage.Request["QuestionType1Count"] != null && CurrentPage.Request["QuestionType1Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType1Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount1"] != null && CurrentPage.Request["QuestionCount1"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount1"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore1"] != null && CurrentPage.Request["SingleQuestionScore1"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore1"].ToString()) : 0;

            ExamQuesTypeMode.ExamSysParaID = ExamSysParaID;
            ExamQuesTypeMode.QuestionType = 192;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;
            ExamQuesTypeMode.Creator = Creator;
            ExamQuesTypeMode.CreateTime = CreateTime;

            DAL.ExamQuestionType ExamQuesTypeDal = new PS.DAL.ExamQuestionType();

            Result = ExamQuesTypeDal.Add(ExamQuesTypeMode);
            if (Result > 0) InsertCount++;

            QuestionType1 = (CurrentPage.Request["QuestionType2Count"] != null && CurrentPage.Request["QuestionType2Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType2Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount2"] != null && CurrentPage.Request["QuestionCount2"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount2"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore2"] != null && CurrentPage.Request["SingleQuestionScore2"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore2"].ToString()) : 0;
            ExamQuesTypeMode.QuestionType = 190;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;
            Result = ExamQuesTypeDal.Add(ExamQuesTypeMode);
            if (Result > 0) InsertCount++;

            QuestionType1 = (CurrentPage.Request["QuestionType3Count"] != null && CurrentPage.Request["QuestionType3Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType3Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount3"] != null && CurrentPage.Request["QuestionCount3"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount3"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore3"] != null && CurrentPage.Request["SingleQuestionScore3"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore3"].ToString()) : 0;
            ExamQuesTypeMode.QuestionType = 191;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;
            int ExamQuestionTypeID = ExamQuesTypeDal.Add(ExamQuesTypeMode);

            if (ExamQuestionTypeID > 0) InsertCount++;
            if (ExamQuestionTypeID > 0)
            {
                //保存权重
                DAL.ExamSysParaWeight ExamWeight = new PS.DAL.ExamSysParaWeight();
                Model.ExamSysParaWeight ExamWeightMode = new PS.Model.ExamSysParaWeight();
                int? Level11_Add = (CurrentPage.Request["Level11_Add"] != null && CurrentPage.Request["Level11_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level11_Add"].ToString()) : 0;
                int? Level12_Add = (CurrentPage.Request["Level12_Add"] != null && CurrentPage.Request["Level12_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level12_Add"].ToString()) : 0;
                int? Level13_Add = (CurrentPage.Request["Level13_Add"] != null && CurrentPage.Request["Level13_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level13_Add"].ToString()) : 0;
                int? Level14_Add = (CurrentPage.Request["Level14_Add"] != null && CurrentPage.Request["Level11_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level14_Add"].ToString()) : 0;
                int? Level15_Add = (CurrentPage.Request["Level15_Add"] != null && CurrentPage.Request["Level15_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level15_Add"].ToString()) : 0;
                int? Level16_Add = (CurrentPage.Request["Level16_Add"] != null && CurrentPage.Request["Level16_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level16_Add"].ToString()) : 0;
                int? Level17_Add = (CurrentPage.Request["Level17_Add"] != null && CurrentPage.Request["Level17_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level17_Add"].ToString()) : 0;
                int? Level18_Add = (CurrentPage.Request["Level18_Add"] != null && CurrentPage.Request["Level18_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level18_Add"].ToString()) : 0;
                int? Level19_Add = (CurrentPage.Request["Level19_Add"] != null && CurrentPage.Request["Level19_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level19_Add"].ToString()) : 0;

                System.Text.StringBuilder StrB = new System.Text.StringBuilder();
                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[Level1],[Level2],[Level3],[Level4],[Level5],[Level6],[Level7],[Level8],[Level9],[Creator],[CreateTime],[Editor],[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 1;
                ExamWeightMode.Level1 = Level11_Add;
                ExamWeightMode.Level2 = Level12_Add;
                ExamWeightMode.Level3 = Level13_Add;
                ExamWeightMode.Level4 = Level14_Add;
                ExamWeightMode.Level5 = Level15_Add;
                ExamWeightMode.Level6 = Level16_Add;
                ExamWeightMode.Level7 = Level17_Add;
                ExamWeightMode.Level8 = Level18_Add;
                ExamWeightMode.Level9 = Level19_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Level4 + "', '" + ExamWeightMode.Level5 + "', '" + ExamWeightMode.Level6 + "', '" + ExamWeightMode.Level7 + "', '" + ExamWeightMode.Level8 + "', '" + ExamWeightMode.Level9 + "', '" + ExamWeightMode.Creator + "',' " + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");


                Level11_Add = (CurrentPage.Request["Level21_Add"] != null && CurrentPage.Request["Level21_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level21_Add"].ToString()) : 0;
                Level12_Add = (CurrentPage.Request["Level22_Add"] != null && CurrentPage.Request["Level22_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level22_Add"].ToString()) : 0;
                Level13_Add = (CurrentPage.Request["Level23_Add"] != null && CurrentPage.Request["Level23_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level23_Add"].ToString()) : 0;
                Level14_Add = (CurrentPage.Request["Level24_Add"] != null && CurrentPage.Request["Level21_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level24_Add"].ToString()) : 0;
                Level15_Add = (CurrentPage.Request["Level25_Add"] != null && CurrentPage.Request["Level25_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level25_Add"].ToString()) : 0;
                Level16_Add = (CurrentPage.Request["Level26_Add"] != null && CurrentPage.Request["Level26_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level26_Add"].ToString()) : 0;
                Level17_Add = (CurrentPage.Request["Level27_Add"] != null && CurrentPage.Request["Level27_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level27_Add"].ToString()) : 0;
                Level18_Add = (CurrentPage.Request["Level28_Add"] != null && CurrentPage.Request["Level28_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level28_Add"].ToString()) : 0;
                Level19_Add = (CurrentPage.Request["Level29_Add"] != null && CurrentPage.Request["Level29_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level29_Add"].ToString()) : 0;

                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[Level1],[Level2],[Level3],[Level4],[Level5],[Level6],[Level7],[Level8],[Level9],[Creator],[CreateTime],[Editor],[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 2;
                ExamWeightMode.Level1 = Level11_Add;
                ExamWeightMode.Level2 = Level12_Add;
                ExamWeightMode.Level3 = Level13_Add;
                ExamWeightMode.Level4 = Level14_Add;
                ExamWeightMode.Level5 = Level15_Add;
                ExamWeightMode.Level6 = Level16_Add;
                ExamWeightMode.Level7 = Level17_Add;
                ExamWeightMode.Level8 = Level18_Add;
                ExamWeightMode.Level9 = Level19_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Level4 + "', '" + ExamWeightMode.Level5 + "', '" + ExamWeightMode.Level6 + "', '" + ExamWeightMode.Level7 + "', '" + ExamWeightMode.Level8 + "', '" + ExamWeightMode.Level9 + "', '" + ExamWeightMode.Creator + "', '" + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");

                Level11_Add = (CurrentPage.Request["Level31_Add"] != null && CurrentPage.Request["Level31_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level31_Add"].ToString()) : 0;
                Level12_Add = (CurrentPage.Request["Level32_Add"] != null && CurrentPage.Request["Level32_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level32_Add"].ToString()) : 0;
                Level13_Add = (CurrentPage.Request["Level33_Add"] != null && CurrentPage.Request["Level33_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level33_Add"].ToString()) : 0;
                Level14_Add = (CurrentPage.Request["Level34_Add"] != null && CurrentPage.Request["Level31_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level34_Add"].ToString()) : 0;
                Level15_Add = (CurrentPage.Request["Level35_Add"] != null && CurrentPage.Request["Level35_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level35_Add"].ToString()) : 0;
                Level16_Add = (CurrentPage.Request["Level36_Add"] != null && CurrentPage.Request["Level36_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level36_Add"].ToString()) : 0;
                Level17_Add = (CurrentPage.Request["Level37_Add"] != null && CurrentPage.Request["Level37_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level37_Add"].ToString()) : 0;
                Level18_Add = (CurrentPage.Request["Level38_Add"] != null && CurrentPage.Request["Level38_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level38_Add"].ToString()) : 0;
                Level19_Add = (CurrentPage.Request["Level39_Add"] != null && CurrentPage.Request["Level39_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level39_Add"].ToString()) : 0;

                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[Level1],[Level2],[Level3],[Level4],[Level5],[Level6],[Level7],[Level8],[Level9],[Creator],[CreateTime],ExamWeightMode.[Editor],ExamWeightMode.[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 3;
                ExamWeightMode.Level1 = Level11_Add;
                ExamWeightMode.Level2 = Level12_Add;
                ExamWeightMode.Level3 = Level13_Add;
                ExamWeightMode.Level4 = Level14_Add;
                ExamWeightMode.Level5 = Level15_Add;
                ExamWeightMode.Level6 = Level16_Add;
                ExamWeightMode.Level7 = Level17_Add;
                ExamWeightMode.Level8 = Level18_Add;
                ExamWeightMode.Level9 = Level19_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Level4 + "', '" + ExamWeightMode.Level5 + "', '" + ExamWeightMode.Level6 + "', '" + ExamWeightMode.Level7 + "', '" + ExamWeightMode.Level8 + "', '" + ExamWeightMode.Level9 + "', '" + ExamWeightMode.Creator + "', '" + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");


                Level11_Add = (CurrentPage.Request["Level41_Add"] != null && CurrentPage.Request["Level41_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level41_Add"].ToString()) : 0;
                Level12_Add = (CurrentPage.Request["Level42_Add"] != null && CurrentPage.Request["Level42_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level42_Add"].ToString()) : 0;
                Level13_Add = (CurrentPage.Request["Level43_Add"] != null && CurrentPage.Request["Level43_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level43_Add"].ToString()) : 0;
                Level14_Add = (CurrentPage.Request["Level44_Add"] != null && CurrentPage.Request["Level44_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level44_Add"].ToString()) : 0;
                Level15_Add = (CurrentPage.Request["Level45_Add"] != null && CurrentPage.Request["Level45_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level45_Add"].ToString()) : 0;
                Level16_Add = (CurrentPage.Request["Level46_Add"] != null && CurrentPage.Request["Level46_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level46_Add"].ToString()) : 0;
                Level17_Add = (CurrentPage.Request["Level47_Add"] != null && CurrentPage.Request["Level47_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level47_Add"].ToString()) : 0;
                Level18_Add = (CurrentPage.Request["Level48_Add"] != null && CurrentPage.Request["Level48_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level48_Add"].ToString()) : 0;
                Level19_Add = (CurrentPage.Request["Level49_Add"] != null && CurrentPage.Request["Level49_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level49_Add"].ToString()) : 0;

                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[Level1],[Level2],[Level3],[Level4],[Level5],[Level6],[Level7],[Level8],[Level9],[Creator],[CreateTime],[Editor],[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 4;
                ExamWeightMode.Level1 = Level11_Add;
                ExamWeightMode.Level2 = Level12_Add;
                ExamWeightMode.Level3 = Level13_Add;
                ExamWeightMode.Level4 = Level14_Add;
                ExamWeightMode.Level5 = Level15_Add;
                ExamWeightMode.Level6 = Level16_Add;
                ExamWeightMode.Level7 = Level17_Add;
                ExamWeightMode.Level8 = Level18_Add;
                ExamWeightMode.Level9 = Level19_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Level4 + "', '" + ExamWeightMode.Level5 + "', '" + ExamWeightMode.Level6 + "', '" + ExamWeightMode.Level7 + "', '" + ExamWeightMode.Level8 + "', '" + ExamWeightMode.Level9 + "', '" + ExamWeightMode.Creator + "', '" + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");

                Level11_Add = (CurrentPage.Request["Level51_Add"] != null && CurrentPage.Request["Level51_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level51_Add"].ToString()) : 0;
                Level12_Add = (CurrentPage.Request["Level52_Add"] != null && CurrentPage.Request["Level52_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level52_Add"].ToString()) : 0;
                Level13_Add = (CurrentPage.Request["Level53_Add"] != null && CurrentPage.Request["Level53_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level53_Add"].ToString()) : 0;
                Level14_Add = (CurrentPage.Request["Level54_Add"] != null && CurrentPage.Request["Level54_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level54_Add"].ToString()) : 0;
                Level15_Add = (CurrentPage.Request["Level55_Add"] != null && CurrentPage.Request["Level55_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level55_Add"].ToString()) : 0;
                Level16_Add = (CurrentPage.Request["Level56_Add"] != null && CurrentPage.Request["Level56_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level56_Add"].ToString()) : 0;
                Level17_Add = (CurrentPage.Request["Level57_Add"] != null && CurrentPage.Request["Level57_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level57_Add"].ToString()) : 0;
                Level18_Add = (CurrentPage.Request["Level58_Add"] != null && CurrentPage.Request["Level58_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level58_Add"].ToString()) : 0;
                Level19_Add = (CurrentPage.Request["Level59_Add"] != null && CurrentPage.Request["Level59_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level59_Add"].ToString()) : 0;

                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[Level1],[Level2],[Level3],[Level4],[Level5],[Level6],[Level7],[Level8],[Level9],[Creator],[CreateTime],[Editor],[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 5;
                ExamWeightMode.Level1 = Level11_Add;
                ExamWeightMode.Level2 = Level12_Add;
                ExamWeightMode.Level3 = Level13_Add;
                ExamWeightMode.Level4 = Level14_Add;
                ExamWeightMode.Level5 = Level15_Add;
                ExamWeightMode.Level6 = Level16_Add;
                ExamWeightMode.Level7 = Level17_Add;
                ExamWeightMode.Level8 = Level18_Add;
                ExamWeightMode.Level9 = Level19_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Level4 + "', '" + ExamWeightMode.Level5 + "', '" + ExamWeightMode.Level6 + "', '" + ExamWeightMode.Level7 + "', '" + ExamWeightMode.Level8 + "', '" + ExamWeightMode.Level9 + "', '" + ExamWeightMode.Creator + "', '" + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");


                //----------------------------
                Level11_Add = (CurrentPage.Request["Level61_Add"] != null && CurrentPage.Request["Level61_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level61_Add"].ToString()) : 0;
                Level12_Add = (CurrentPage.Request["Level62_Add"] != null && CurrentPage.Request["Level62_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level62_Add"].ToString()) : 0;
                Level13_Add = (CurrentPage.Request["Level63_Add"] != null && CurrentPage.Request["Level63_Add"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level63_Add"].ToString()) : 0;

                StrB.Append("INSERT INTO [ExamSysParaWeight]([ExamSysParaID],[WeightType],[ManageKnowledge],[ArticleWrite],[SpecialKnowledge],[Creator],[CreateTime],[Editor],[EditTime])  ");
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 6;
                ExamWeightMode.ManageKnowledge = Level11_Add;
                ExamWeightMode.ArticleWrite = Level12_Add;
                ExamWeightMode.SpecialKnowledge = Level13_Add;

                StrB.Append("VALUES('" + ExamWeightMode.ExamSysParaID + "', '" + ExamWeightMode.WeightType + "', '" + ExamWeightMode.Level1 + "', '" + ExamWeightMode.Level2 + "', '" + ExamWeightMode.Level3 + "', '" + ExamWeightMode.Creator + "', '" + ExamWeightMode.CreateTime + "', '" + ExamWeightMode.Editor + "', '" + ExamWeightMode.EditTime + "');");
                string SqlString = StrB.ToString();
                Result = PS.DBUtility.DbHelperSQL.ExecuteSql(SqlString);
                if (Result > 0) InsertCount += Result;
            }

            Result = InsertCount;
            if (InsertCount < 10)
            {
                //保存数据失败,删除不完整数据
                Delete(ExamSysParaID);
                Result = 0;
            }
            return Result;
        }

        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="SqlString"></param>
        /// <returns></returns>
        public int UpDateSysPara(string SqlString)
        {
            int Rows = DbHelperSQL.ExecuteSql(SqlString);
            return Rows;
        }

        /// <summary>
        /// 修改一条参数
        /// </summary>
        /// <param name="CurrentPage">当前页</param>
        /// <param name="CurrentUser">当前用户</param>
        /// <returns>正确添加返回1，失败返回0</returns>
        public int UpDateSysPara(Page CurrentPage, string CurrentUser)
        {
            bool UpDateResult = false;
            int UpDateCount = 0;
            int Result = 0;
            int ExamSysParaID = (CurrentPage.Request["ExamSysParaID"] != null && CurrentPage.Request["ExamSysParaID"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaID"].ToString()) : 0;


            string Spare1 = (CurrentPage.Request["ExamName"] != null && CurrentPage.Request["ExamName"].ToString().Length > 0) ? CurrentPage.Request["ExamName"].ToString().Trim() : "";

            int? ExamTimes = (CurrentPage.Request["ExamTimes"] != null && CurrentPage.Request["ExamTimes"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamTimes"].ToString()) : 0;
            int? ExamTime = (CurrentPage.Request["ExamTime"] != null && CurrentPage.Request["ExamTime"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamTime"].ToString()) : 0;
            string ExamDescription = (CurrentPage.Request["ExamDescription"] != null && CurrentPage.Request["ExamDescription"].ToString().Length > 0) ? CurrentPage.Request["ExamDescription"].ToString() : "";
            int QuestionsTotal = (CurrentPage.Request["QuestionsTotal"] != null && CurrentPage.Request["QuestionsTotal"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionsTotal"].ToString()) : 0;
            string Creator = CurrentUser;

            DateTime? CreateTime = System.DateTime.Now;
            decimal SumScore = (CurrentPage.Request["SumScore"] != null && CurrentPage.Request["SumScore"].ToString().Length > 0) ? decimal.Parse(CurrentPage.Request["SumScore"].ToString()) : 0;
            int? ExamType = (CurrentPage.Request["ExamType"] != null && CurrentPage.Request["ExamType"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamType"].ToString()) : 0;
            DateTime? ExamStartDate = DateTime.Parse(CurrentPage.Request["ExamStartDate"].ToString());
            DateTime? ExamFinishDate = DateTime.Parse(CurrentPage.Request["ExamFinishDate"].ToString());

            Model.ExamSysPara ExamParaMode = GetModel(ExamSysParaID)  ;
            ExamParaMode.ExamSysParaID = ExamSysParaID;
            ExamParaMode.ExamTimes = ExamTimes;
            ExamParaMode.ExamTime = ExamTime;
            ExamParaMode.ExamDescription = ExamDescription;
            ExamParaMode.QuestionsTotal = QuestionsTotal;
            ExamParaMode.Creator = Creator;
            ExamParaMode.CreateTime = CreateTime;
            ExamParaMode.SumScore = SumScore;
            ExamParaMode.ExamType = ExamType;
            ExamParaMode.ExamStartDate = ExamStartDate;
            ExamParaMode.ExamFinishDate = ExamFinishDate;
            ExamParaMode.Spare1 = Spare1;

            DAL.ExamSysPara ExamPara = new PS.DAL.ExamSysPara();
            UpDateResult = ExamPara.Update(ExamParaMode);
            if (UpDateResult == true) UpDateCount++;

            Model.ExamQuestionType ExamQuesTypeMode = new PS.Model.ExamQuestionType();
            int QuestionType1 = 0;
            int? QuestionCount1 = 0;
            decimal? SingleQuestionScore1 = 0;
            int ExamQuestionTypeID1 = (CurrentPage.Request["ExamQuestionTypeID1_Mod"] != null && CurrentPage.Request["ExamQuestionTypeID1_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamQuestionTypeID1_Mod"].ToString()) : 0;

            QuestionType1 = (CurrentPage.Request["QuestionType1Count"] != null && CurrentPage.Request["QuestionType1Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType1Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount1"] != null && CurrentPage.Request["QuestionCount1"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount1"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore1"] != null && CurrentPage.Request["SingleQuestionScore1"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore1"].ToString()) : 0;

            ExamQuesTypeMode.ExamQuestionTypeID = ExamQuestionTypeID1;
            ExamQuesTypeMode.ExamSysParaID = ExamSysParaID;
            ExamQuesTypeMode.QuestionType = 192;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;
            ExamQuesTypeMode.Editor = Creator;
            ExamQuesTypeMode.EditTime = CreateTime;

            DAL.ExamQuestionType ExamQuesTypeDal = new PS.DAL.ExamQuestionType();

            UpDateResult = ExamQuesTypeDal.Update(ExamQuesTypeMode);
            if (UpDateResult == true) UpDateCount++;

            int ExamQuestionTypeID2 = (CurrentPage.Request["ExamQuestionTypeID2_Mod"] != null && CurrentPage.Request["ExamQuestionTypeID2_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamQuestionTypeID2_Mod"].ToString()) : 0;
            QuestionType1 = (CurrentPage.Request["QuestionType2Count"] != null && CurrentPage.Request["QuestionType2Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType2Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount2"] != null && CurrentPage.Request["QuestionCount2"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount2"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore2"] != null && CurrentPage.Request["SingleQuestionScore2"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore2"].ToString()) : 0;
            ExamQuesTypeMode.ExamQuestionTypeID = ExamQuestionTypeID2;
            ExamQuesTypeMode.QuestionType = 190;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;
            UpDateResult = ExamQuesTypeDal.Update(ExamQuesTypeMode);
            if (UpDateResult == true) UpDateCount++;

            int ExamQuestionTypeID3 = (CurrentPage.Request["ExamQuestionTypeID3_Mod"] != null && CurrentPage.Request["ExamQuestionTypeID3_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamQuestionTypeID3_Mod"].ToString()) : 0;
            QuestionType1 = (CurrentPage.Request["QuestionType3Count"] != null && CurrentPage.Request["QuestionType3Count"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionType3Count"].ToString()) : 0;
            QuestionCount1 = (CurrentPage.Request["QuestionCount3"] != null && CurrentPage.Request["QuestionCount3"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["QuestionCount3"].ToString()) : 0;
            SingleQuestionScore1 = (CurrentPage.Request["SingleQuestionScore3"] != null && CurrentPage.Request["SingleQuestionScore3"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["SingleQuestionScore3"].ToString()) : 0;
            ExamQuesTypeMode.ExamQuestionTypeID = ExamQuestionTypeID3;
            ExamQuesTypeMode.QuestionType = 191;
            ExamQuesTypeMode.QuestionCount = QuestionType1;
            ExamQuesTypeMode.SingleQuestionScore = SingleQuestionScore1;

            UpDateResult = ExamQuesTypeDal.Update(ExamQuesTypeMode);
            if (UpDateResult == true) UpDateCount++;

            if (UpDateCount > 0)
            {
                //保存权重
                DAL.ExamSysParaWeight ExamWeight = new PS.DAL.ExamSysParaWeight();
                Model.ExamSysParaWeight ExamWeightMode = new PS.Model.ExamSysParaWeight();

                int ExamSysParaWeightID1_Mod = (CurrentPage.Request["ExamSysParaWeightID1_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID1_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID1_Mod"].ToString()) : 0;
                int? Level11_Mod = (CurrentPage.Request["Level11_Mod"] != null && CurrentPage.Request["Level11_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level11_Mod"].ToString()) : 0;
                int? Level12_Mod = (CurrentPage.Request["Level12_Mod"] != null && CurrentPage.Request["Level12_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level12_Mod"].ToString()) : 0;
                int? Level13_Mod = (CurrentPage.Request["Level13_Mod"] != null && CurrentPage.Request["Level13_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level13_Mod"].ToString()) : 0;
                int? Level14_Mod = (CurrentPage.Request["Level14_Mod"] != null && CurrentPage.Request["Level11_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level14_Mod"].ToString()) : 0;
                int? Level15_Mod = (CurrentPage.Request["Level15_Mod"] != null && CurrentPage.Request["Level15_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level15_Mod"].ToString()) : 0;
                int? Level16_Mod = (CurrentPage.Request["Level16_Mod"] != null && CurrentPage.Request["Level16_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level16_Mod"].ToString()) : 0;
                int? Level17_Mod = (CurrentPage.Request["Level17_Mod"] != null && CurrentPage.Request["Level17_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level17_Mod"].ToString()) : 0;
                int? Level18_Mod = (CurrentPage.Request["Level18_Mod"] != null && CurrentPage.Request["Level18_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level18_Mod"].ToString()) : 0;
                int? Level19_Mod = (CurrentPage.Request["Level19_Mod"] != null && CurrentPage.Request["Level19_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level19_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID1_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 1;
                ExamWeightMode.Level1 = Level11_Mod;
                ExamWeightMode.Level2 = Level12_Mod;
                ExamWeightMode.Level3 = Level13_Mod;
                ExamWeightMode.Level4 = Level14_Mod;
                ExamWeightMode.Level5 = Level15_Mod;
                ExamWeightMode.Level6 = Level16_Mod;
                ExamWeightMode.Level7 = Level17_Mod;
                ExamWeightMode.Level8 = Level18_Mod;
                ExamWeightMode.Level9 = Level19_Mod;
                ExamWeight.Update(ExamWeightMode);

                int ExamSysParaWeightID2_Mod = (CurrentPage.Request["ExamSysParaWeightID2_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID2_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID2_Mod"].ToString()) : 0;
                Level11_Mod = (CurrentPage.Request["Level21_Mod"] != null && CurrentPage.Request["Level21_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level21_Mod"].ToString()) : 0;
                Level12_Mod = (CurrentPage.Request["Level22_Mod"] != null && CurrentPage.Request["Level22_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level22_Mod"].ToString()) : 0;
                Level13_Mod = (CurrentPage.Request["Level23_Mod"] != null && CurrentPage.Request["Level23_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level23_Mod"].ToString()) : 0;
                Level14_Mod = (CurrentPage.Request["Level24_Mod"] != null && CurrentPage.Request["Level21_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level24_Mod"].ToString()) : 0;
                Level15_Mod = (CurrentPage.Request["Level25_Mod"] != null && CurrentPage.Request["Level25_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level25_Mod"].ToString()) : 0;
                Level16_Mod = (CurrentPage.Request["Level26_Mod"] != null && CurrentPage.Request["Level26_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level26_Mod"].ToString()) : 0;
                Level17_Mod = (CurrentPage.Request["Level27_Mod"] != null && CurrentPage.Request["Level27_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level27_Mod"].ToString()) : 0;
                Level18_Mod = (CurrentPage.Request["Level28_Mod"] != null && CurrentPage.Request["Level28_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level28_Mod"].ToString()) : 0;
                Level19_Mod = (CurrentPage.Request["Level29_Mod"] != null && CurrentPage.Request["Level29_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level29_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID2_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 2;
                ExamWeightMode.Level1 = Level11_Mod;
                ExamWeightMode.Level2 = Level12_Mod;
                ExamWeightMode.Level3 = Level13_Mod;
                ExamWeightMode.Level4 = Level14_Mod;
                ExamWeightMode.Level5 = Level15_Mod;
                ExamWeightMode.Level6 = Level16_Mod;
                ExamWeightMode.Level7 = Level17_Mod;
                ExamWeightMode.Level8 = Level18_Mod;
                ExamWeightMode.Level9 = Level19_Mod;

                ExamWeight.Update(ExamWeightMode);

                int ExamSysParaWeightID3_Mod = (CurrentPage.Request["ExamSysParaWeightID3_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID3_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID3_Mod"].ToString()) : 0;
                Level11_Mod = (CurrentPage.Request["Level31_Mod"] != null && CurrentPage.Request["Level31_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level31_Mod"].ToString()) : 0;
                Level12_Mod = (CurrentPage.Request["Level32_Mod"] != null && CurrentPage.Request["Level32_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level32_Mod"].ToString()) : 0;
                Level13_Mod = (CurrentPage.Request["Level33_Mod"] != null && CurrentPage.Request["Level33_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level33_Mod"].ToString()) : 0;
                Level14_Mod = (CurrentPage.Request["Level34_Mod"] != null && CurrentPage.Request["Level31_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level34_Mod"].ToString()) : 0;
                Level15_Mod = (CurrentPage.Request["Level35_Mod"] != null && CurrentPage.Request["Level35_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level35_Mod"].ToString()) : 0;
                Level16_Mod = (CurrentPage.Request["Level36_Mod"] != null && CurrentPage.Request["Level36_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level36_Mod"].ToString()) : 0;
                Level17_Mod = (CurrentPage.Request["Level37_Mod"] != null && CurrentPage.Request["Level37_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level37_Mod"].ToString()) : 0;
                Level18_Mod = (CurrentPage.Request["Level38_Mod"] != null && CurrentPage.Request["Level38_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level38_Mod"].ToString()) : 0;
                Level19_Mod = (CurrentPage.Request["Level39_Mod"] != null && CurrentPage.Request["Level39_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level39_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID3_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 3;
                ExamWeightMode.Level1 = Level11_Mod;
                ExamWeightMode.Level2 = Level12_Mod;
                ExamWeightMode.Level3 = Level13_Mod;
                ExamWeightMode.Level4 = Level14_Mod;
                ExamWeightMode.Level5 = Level15_Mod;
                ExamWeightMode.Level6 = Level16_Mod;
                ExamWeightMode.Level7 = Level17_Mod;
                ExamWeightMode.Level8 = Level18_Mod;
                ExamWeightMode.Level9 = Level19_Mod;

                ExamWeight.Update(ExamWeightMode);

                int ExamSysParaWeightID4_Mod = (CurrentPage.Request["ExamSysParaWeightID4_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID4_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID4_Mod"].ToString()) : 0;
                Level11_Mod = (CurrentPage.Request["Level41_Mod"] != null && CurrentPage.Request["Level41_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level41_Mod"].ToString()) : 0;
                Level12_Mod = (CurrentPage.Request["Level42_Mod"] != null && CurrentPage.Request["Level42_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level42_Mod"].ToString()) : 0;
                Level13_Mod = (CurrentPage.Request["Level43_Mod"] != null && CurrentPage.Request["Level43_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level43_Mod"].ToString()) : 0;
                Level14_Mod = (CurrentPage.Request["Level44_Mod"] != null && CurrentPage.Request["Level44_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level44_Mod"].ToString()) : 0;
                Level15_Mod = (CurrentPage.Request["Level45_Mod"] != null && CurrentPage.Request["Level45_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level45_Mod"].ToString()) : 0;
                Level16_Mod = (CurrentPage.Request["Level46_Mod"] != null && CurrentPage.Request["Level46_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level46_Mod"].ToString()) : 0;
                Level17_Mod = (CurrentPage.Request["Level47_Mod"] != null && CurrentPage.Request["Level47_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level47_Mod"].ToString()) : 0;
                Level18_Mod = (CurrentPage.Request["Level48_Mod"] != null && CurrentPage.Request["Level48_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level48_Mod"].ToString()) : 0;
                Level19_Mod = (CurrentPage.Request["Level49_Mod"] != null && CurrentPage.Request["Level49_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level49_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID4_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 4;
                ExamWeightMode.Level1 = Level11_Mod;
                ExamWeightMode.Level2 = Level12_Mod;
                ExamWeightMode.Level3 = Level13_Mod;
                ExamWeightMode.Level4 = Level14_Mod;
                ExamWeightMode.Level5 = Level15_Mod;
                ExamWeightMode.Level6 = Level16_Mod;
                ExamWeightMode.Level7 = Level17_Mod;
                ExamWeightMode.Level8 = Level18_Mod;
                ExamWeightMode.Level9 = Level19_Mod;

                ExamWeight.Update(ExamWeightMode);

                int ExamSysParaWeightID5_Mod = (CurrentPage.Request["ExamSysParaWeightID5_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID5_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID5_Mod"].ToString()) : 0;
                Level11_Mod = (CurrentPage.Request["Level51_Mod"] != null && CurrentPage.Request["Level51_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level51_Mod"].ToString()) : 0;
                Level12_Mod = (CurrentPage.Request["Level52_Mod"] != null && CurrentPage.Request["Level52_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level52_Mod"].ToString()) : 0;
                Level13_Mod = (CurrentPage.Request["Level53_Mod"] != null && CurrentPage.Request["Level53_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level53_Mod"].ToString()) : 0;
                Level14_Mod = (CurrentPage.Request["Level54_Mod"] != null && CurrentPage.Request["Level54_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level54_Mod"].ToString()) : 0;
                Level15_Mod = (CurrentPage.Request["Level55_Mod"] != null && CurrentPage.Request["Level55_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level55_Mod"].ToString()) : 0;
                Level16_Mod = (CurrentPage.Request["Level56_Mod"] != null && CurrentPage.Request["Level56_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level56_Mod"].ToString()) : 0;
                Level17_Mod = (CurrentPage.Request["Level57_Mod"] != null && CurrentPage.Request["Level57_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level57_Mod"].ToString()) : 0;
                Level18_Mod = (CurrentPage.Request["Level58_Mod"] != null && CurrentPage.Request["Level58_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level58_Mod"].ToString()) : 0;
                Level19_Mod = (CurrentPage.Request["Level59_Mod"] != null && CurrentPage.Request["Level59_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level59_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID5_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 5;
                ExamWeightMode.Level1 = Level11_Mod;
                ExamWeightMode.Level2 = Level12_Mod;
                ExamWeightMode.Level3 = Level13_Mod;
                ExamWeightMode.Level4 = Level14_Mod;
                ExamWeightMode.Level5 = Level15_Mod;
                ExamWeightMode.Level6 = Level16_Mod;
                ExamWeightMode.Level7 = Level17_Mod;
                ExamWeightMode.Level8 = Level18_Mod;
                ExamWeightMode.Level9 = Level19_Mod;

                ExamWeight.Update(ExamWeightMode);

                //----------------------------
                int ExamSysParaWeightID6_Mod = (CurrentPage.Request["ExamSysParaWeightID6_Mod"] != null && CurrentPage.Request["ExamSysParaWeightID6_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["ExamSysParaWeightID6_Mod"].ToString()) : 0;
                Level11_Mod = (CurrentPage.Request["Level61_Mod"] != null && CurrentPage.Request["Level61_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level61_Mod"].ToString()) : 0;
                Level12_Mod = (CurrentPage.Request["Level62_Mod"] != null && CurrentPage.Request["Level62_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level62_Mod"].ToString()) : 0;
                Level13_Mod = (CurrentPage.Request["Level63_Mod"] != null && CurrentPage.Request["Level63_Mod"].ToString().Length > 0) ? int.Parse(CurrentPage.Request["Level63_Mod"].ToString()) : 0;

                ExamWeightMode.ExamSysParaWeightID = ExamSysParaWeightID6_Mod;
                ExamWeightMode.ExamSysParaID = ExamSysParaID;
                ExamWeightMode.Creator = Creator;
                ExamWeightMode.CreateTime = CreateTime;
                ExamWeightMode.Editor = "";
                ExamWeightMode.EditTime = null;

                ExamWeightMode.WeightType = 6;
                ExamWeightMode.ManageKnowledge = Level11_Mod;
                ExamWeightMode.ArticleWrite = Level12_Mod;
                ExamWeightMode.SpecialKnowledge = Level13_Mod;

                UpDateResult = ExamWeight.Update(ExamWeightMode);
                if (UpDateResult == true) Result = 1;
            }

            return Result;
        }



        /// <summary>
        /// 保存绩效考核设置参数
        /// </summary>
        /// <returns></returns>
        public int SavePara()
        {
            int Result = 0;


            return Result;
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(PS.Model.ExamSysPara model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into ExamSysPara(");
            strSql.Append("SumScore,ExamTime,ExamTimes,QuestionsTotal,PassScore,ExamDescription,ExamType,Creator,ExamStartDate,ExamFinishDate,CreateTime,Editor,EditTime,DispOrder,ValidMark,Spare1,Spare2,Spare3,Spare4,SpareDecimal5,SpareDecimal6,SpareDecimal7,SpareDecimal8,CurrentPara)");
            strSql.Append(" values (");
            strSql.Append("@SumScore,@ExamTime,@ExamTimes,@QuestionsTotal,@PassScore,@ExamDescription,@ExamType,@Creator,@ExamStartDate,@ExamFinishDate,@CreateTime,@Editor,@EditTime,@DispOrder,@ValidMark,@Spare1,@Spare2,@Spare3,@Spare4,@SpareDecimal5,@SpareDecimal6,@SpareDecimal7,@SpareDecimal8,@CurrentPara)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@SumScore", SqlDbType.Decimal,9),
					new SqlParameter("@ExamTime", SqlDbType.Int,4),
					new SqlParameter("@ExamTimes", SqlDbType.Int,4),
					new SqlParameter("@QuestionsTotal", SqlDbType.Int,4),
					new SqlParameter("@PassScore", SqlDbType.Decimal,9),
					new SqlParameter("@ExamDescription", SqlDbType.VarChar,2000),
					new SqlParameter("@ExamType", SqlDbType.Int,4),
					new SqlParameter("@Creator", SqlDbType.VarChar,20),
					new SqlParameter("@ExamStartDate", SqlDbType.DateTime),
					new SqlParameter("@ExamFinishDate", SqlDbType.DateTime),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@Editor", SqlDbType.VarChar,20),
					new SqlParameter("@EditTime", SqlDbType.DateTime),
					new SqlParameter("@DispOrder", SqlDbType.Int,4),
					new SqlParameter("@ValidMark", SqlDbType.Int,4),
					new SqlParameter("@Spare1", SqlDbType.VarChar,200),
					new SqlParameter("@Spare2", SqlDbType.VarChar,200),
					new SqlParameter("@Spare3", SqlDbType.VarChar,200),
					new SqlParameter("@Spare4", SqlDbType.VarChar,200),
					new SqlParameter("@SpareDecimal5", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal6", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal7", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal8", SqlDbType.Decimal,9),
					new SqlParameter("@CurrentPara", SqlDbType.Bit,1)}; 
            parameters[0].Value = model.SumScore;
            parameters[1].Value = model.ExamTime;
            parameters[2].Value = model.ExamTimes;
            parameters[3].Value = model.QuestionsTotal;
            parameters[4].Value = model.PassScore;
            parameters[5].Value = model.ExamDescription;
            parameters[6].Value = model.ExamType;
            parameters[7].Value = model.Creator;
            parameters[8].Value = model.ExamStartDate;
            parameters[9].Value = model.ExamFinishDate;
            parameters[10].Value = model.CreateTime;
            parameters[11].Value = model.Editor;
            parameters[12].Value = model.EditTime;
            parameters[13].Value = model.DispOrder;
            parameters[14].Value = model.ValidMark;
            parameters[15].Value = model.Spare1;
            parameters[16].Value = model.Spare2;
            parameters[17].Value = model.Spare3;
            parameters[18].Value = model.Spare4;
            parameters[19].Value = model.SpareDecimal5;
            parameters[20].Value = model.SpareDecimal6;
            parameters[21].Value = model.SpareDecimal7;
            parameters[22].Value = model.SpareDecimal8;
            parameters[23].Value = model.CurrentPara;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PS.Model.ExamSysPara model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update ExamSysPara set ");
            strSql.Append("SumScore=@SumScore,");
            strSql.Append("ExamTime=@ExamTime,");
            strSql.Append("ExamTimes=@ExamTimes,");
            strSql.Append("QuestionsTotal=@QuestionsTotal,");
            strSql.Append("PassScore=@PassScore,");
            strSql.Append("ExamDescription=@ExamDescription,");
            strSql.Append("ExamType=@ExamType,");
            strSql.Append("Creator=@Creator,");
            strSql.Append("ExamStartDate=@ExamStartDate,");
            strSql.Append("ExamFinishDate=@ExamFinishDate,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("Editor=@Editor,");
            strSql.Append("EditTime=@EditTime,");
            strSql.Append("DispOrder=@DispOrder,");
            strSql.Append("ValidMark=@ValidMark,");
            strSql.Append("Spare1=@Spare1,");
            strSql.Append("Spare2=@Spare2,");
            strSql.Append("Spare3=@Spare3,");
            strSql.Append("Spare4=@Spare4,");
            strSql.Append("SpareDecimal5=@SpareDecimal5,");
            strSql.Append("SpareDecimal6=@SpareDecimal6,");
            strSql.Append("SpareDecimal7=@SpareDecimal7,");
            strSql.Append("SpareDecimal8=@SpareDecimal8,");
            strSql.Append("CurrentPara=@CurrentPara");
            strSql.Append(" where ExamSysParaID=@ExamSysParaID");
            SqlParameter[] parameters = {
					new SqlParameter("@SumScore", SqlDbType.Decimal,9),
					new SqlParameter("@ExamTime", SqlDbType.Int,4),
					new SqlParameter("@ExamTimes", SqlDbType.Int,4),
					new SqlParameter("@QuestionsTotal", SqlDbType.Int,4),
					new SqlParameter("@PassScore", SqlDbType.Decimal,9),
					new SqlParameter("@ExamDescription", SqlDbType.VarChar,2000),
					new SqlParameter("@ExamType", SqlDbType.Int,4),
					new SqlParameter("@Creator", SqlDbType.VarChar,20),
					new SqlParameter("@ExamStartDate", SqlDbType.DateTime),
					new SqlParameter("@ExamFinishDate", SqlDbType.DateTime),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@Editor", SqlDbType.VarChar,20),
					new SqlParameter("@EditTime", SqlDbType.DateTime),
					new SqlParameter("@DispOrder", SqlDbType.Int,4),
					new SqlParameter("@ValidMark", SqlDbType.Int,4),
					new SqlParameter("@Spare1", SqlDbType.VarChar,200),
					new SqlParameter("@Spare2", SqlDbType.VarChar,200),
					new SqlParameter("@Spare3", SqlDbType.VarChar,200),
					new SqlParameter("@Spare4", SqlDbType.VarChar,200),
					new SqlParameter("@SpareDecimal5", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal6", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal7", SqlDbType.Decimal,9),
					new SqlParameter("@SpareDecimal8", SqlDbType.Decimal,9),
					new SqlParameter("@CurrentPara", SqlDbType.Bit,1 ),  
					new SqlParameter("@ExamSysParaID", SqlDbType.Int,4)};
            parameters[0].Value = model.SumScore;
            parameters[1].Value = model.ExamTime;
            parameters[2].Value = model.ExamTimes;
            parameters[3].Value = model.QuestionsTotal;
            parameters[4].Value = model.PassScore;
            parameters[5].Value = model.ExamDescription;
            parameters[6].Value = model.ExamType;
            parameters[7].Value = model.Creator;
            parameters[8].Value = model.ExamStartDate;
            parameters[9].Value = model.ExamFinishDate;
            parameters[10].Value = model.CreateTime;
            parameters[11].Value = model.Editor;
            parameters[12].Value = model.EditTime;
            parameters[13].Value = model.DispOrder;
            parameters[14].Value = model.ValidMark;
            parameters[15].Value = model.Spare1;
            parameters[16].Value = model.Spare2;
            parameters[17].Value = model.Spare3;
            parameters[18].Value = model.Spare4;
            parameters[19].Value = model.SpareDecimal5;
            parameters[20].Value = model.SpareDecimal6;
            parameters[21].Value = model.SpareDecimal7;
            parameters[22].Value = model.SpareDecimal8;
            parameters[23].Value = model.CurrentPara;

            parameters[24].Value = model.ExamSysParaID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ExamSysParaID)
        {

            StringBuilder strSql = new StringBuilder();
            //1.删除ExamQuestionType中的数据
            string SqlString = "delete from ExamQuestionType where ExamSysParaID=" + ExamSysParaID;

            int rows = DbHelperSQL.ExecuteSql(SqlString);
            SqlString = "delete from ExamSysParaWeight where ExamSysParaID=" + ExamSysParaID;

            rows = DbHelperSQL.ExecuteSql(SqlString);


            strSql.Append("delete from ExamSysPara ");
            strSql.Append(" where ExamSysParaID=@ExamSysParaID");
            SqlParameter[] parameters = {
					new SqlParameter("@ExamSysParaID", SqlDbType.Int,4)
};
            parameters[0].Value = ExamSysParaID;

            rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string ExamSysParaIDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from ExamSysPara ");
            strSql.Append(" where ExamSysParaID in (" + ExamSysParaIDlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PS.Model.ExamSysPara GetModel(int ExamSysParaID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ExamSysParaID,SumScore,ExamTime,ExamTimes,QuestionsTotal,PassScore,ExamDescription,ExamType,Creator,ExamStartDate,ExamFinishDate,CreateTime,Editor,EditTime,DispOrder,ValidMark,Spare1,Spare2,Spare3,Spare4,SpareDecimal5,SpareDecimal6,SpareDecimal7,SpareDecimal8,CurrentPara from ExamSysPara ");
            strSql.Append(" where ExamSysParaID=@ExamSysParaID");
            SqlParameter[] parameters = {
					new SqlParameter("@ExamSysParaID", SqlDbType.Int,4)
};
            parameters[0].Value = ExamSysParaID;

            PS.Model.ExamSysPara model = new PS.Model.ExamSysPara();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ExamSysParaID"].ToString() != "")
                {
                    model.ExamSysParaID = int.Parse(ds.Tables[0].Rows[0]["ExamSysParaID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumScore"].ToString() != "")
                {
                    model.SumScore = decimal.Parse(ds.Tables[0].Rows[0]["SumScore"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamTime"].ToString() != "")
                {
                    model.ExamTime = int.Parse(ds.Tables[0].Rows[0]["ExamTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamTimes"].ToString() != "")
                {
                    model.ExamTimes = int.Parse(ds.Tables[0].Rows[0]["ExamTimes"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QuestionsTotal"].ToString() != "")
                {
                    model.QuestionsTotal = int.Parse(ds.Tables[0].Rows[0]["QuestionsTotal"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PassScore"].ToString() != "")
                {
                    model.PassScore = decimal.Parse(ds.Tables[0].Rows[0]["PassScore"].ToString());
                }
                model.ExamDescription = ds.Tables[0].Rows[0]["ExamDescription"].ToString();
                if (ds.Tables[0].Rows[0]["ExamType"].ToString() != "")
                {
                    model.ExamType = int.Parse(ds.Tables[0].Rows[0]["ExamType"].ToString());
                }
                model.Creator = ds.Tables[0].Rows[0]["Creator"].ToString();
                if (ds.Tables[0].Rows[0]["ExamStartDate"].ToString() != "")
                {
                    model.ExamStartDate = DateTime.Parse(ds.Tables[0].Rows[0]["ExamStartDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamFinishDate"].ToString() != "")
                {
                    model.ExamFinishDate = DateTime.Parse(ds.Tables[0].Rows[0]["ExamFinishDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                model.Editor = ds.Tables[0].Rows[0]["Editor"].ToString();
                if (ds.Tables[0].Rows[0]["EditTime"].ToString() != "")
                {
                    model.EditTime = DateTime.Parse(ds.Tables[0].Rows[0]["EditTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DispOrder"].ToString() != "")
                {
                    model.DispOrder = int.Parse(ds.Tables[0].Rows[0]["DispOrder"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ValidMark"].ToString() != "")
                {
                    model.ValidMark = int.Parse(ds.Tables[0].Rows[0]["ValidMark"].ToString());
                }
                model.Spare1 = ds.Tables[0].Rows[0]["Spare1"].ToString();
                model.Spare2 = ds.Tables[0].Rows[0]["Spare2"].ToString();
                model.Spare3 = ds.Tables[0].Rows[0]["Spare3"].ToString();
                model.Spare4 = ds.Tables[0].Rows[0]["Spare4"].ToString();
                if (ds.Tables[0].Rows[0]["SpareDecimal5"].ToString() != "")
                {
                    model.SpareDecimal5 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal5"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal6"].ToString() != "")
                {
                    model.SpareDecimal6 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal6"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal7"].ToString() != "")
                {
                    model.SpareDecimal7 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal7"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal8"].ToString() != "")
                {
                    model.SpareDecimal8 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal8"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CurrentPara"].ToString() != "")
                {
                    model.CurrentPara = Convert.ToBoolean(ds.Tables[0].Rows[0]["CurrentPara"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        public DataSet GetCurrentSysPara()
        {
            DataSet ds = GetList(1, " ValidMark=1 AND CurrentPara=1", " ExamSysParaID DESC ");
            //没有参数的处理 
            return ds;
        }

        public PS.Model.ExamSysPara CurrentSysPara
        {
            get
            {
                DataSet ds = GetCurrentSysPara();
                PS.Model.ExamSysPara result = GetModelByDataSet(ds);
                if(result!=null && ( result.ExamStartDate.Value.Month != System.DateTime.Now.Month || result.ExamStartDate.Value.Year != System.DateTime.Now.Year))
                {
                    //没有参数的处理 
                    PS.DAL.ExamQuestionType et = new ExamQuestionType();
                    List<PS.Model.ExamQuestionType> eqts = et.GetListModel(" ExamSysParaID=" + result.ExamSysParaID);

                    PS.DAL.ExamSysParaWeight es = new ExamSysParaWeight();
                    List<PS.Model.ExamSysParaWeight> esps = es.GetListModel(" ExamSysParaID=" + result.ExamSysParaID);

                    result.CurrentPara = false;
                    Update(result);

                    PS.Model.ExamSysPara result1 = GetModelByDataSet(ds);
                    result1.ExamStartDate = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, result.ExamStartDate.Value.Day);
                    result1.ExamFinishDate = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, result.ExamFinishDate.Value.Day) .AddDays(1).AddMilliseconds(-1);
                    result1.ExamSysParaID = 0;
                    Add(result1);
                    result = GetModelByDataSet(ds);
                    foreach (PS.Model.ExamQuestionType eqt in eqts)
                    {
                        eqt.ExamQuestionTypeID = 0;
                        eqt.ExamSysParaID = result.ExamSysParaID;
                        et.Add(eqt);
                    }
                    foreach (PS.Model.ExamSysParaWeight esp in esps)
                    {
                        esp.ExamSysParaWeightID = 0;
                        esp.ExamSysParaID = result.ExamSysParaID;
                        es.Add(esp);
                    }
                }

                return result;
            }
        }
        /// <summary>
        /// 得到一个对象实体 
        /// </summary>
        public PS.Model.ExamSysPara GetModelByDataSet(DataSet ds)
        {
            PS.Model.ExamSysPara model = new PS.Model.ExamSysPara();
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ExamSysParaID"].ToString() != "")
                {
                    model.ExamSysParaID = int.Parse(ds.Tables[0].Rows[0]["ExamSysParaID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumScore"].ToString() != "")
                {
                    model.SumScore = decimal.Parse(ds.Tables[0].Rows[0]["SumScore"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamTime"].ToString() != "")
                {
                    model.ExamTime = int.Parse(ds.Tables[0].Rows[0]["ExamTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamTimes"].ToString() != "")
                {
                    model.ExamTimes = int.Parse(ds.Tables[0].Rows[0]["ExamTimes"].ToString());
                }
                if (ds.Tables[0].Rows[0]["QuestionsTotal"].ToString() != "")
                {
                    model.QuestionsTotal = int.Parse(ds.Tables[0].Rows[0]["QuestionsTotal"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PassScore"].ToString() != "")
                {
                    model.PassScore = decimal.Parse(ds.Tables[0].Rows[0]["PassScore"].ToString());
                }
                model.ExamDescription = ds.Tables[0].Rows[0]["ExamDescription"].ToString();
                model.Creator = ds.Tables[0].Rows[0]["Creator"].ToString();
                if (ds.Tables[0].Rows[0]["ExamStartDate"].ToString() != "")
                {
                    model.ExamStartDate = DateTime.Parse(ds.Tables[0].Rows[0]["ExamStartDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExamFinishDate"].ToString() != "")
                {
                    model.ExamFinishDate = DateTime.Parse(ds.Tables[0].Rows[0]["ExamFinishDate"].ToString());
                }

                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                model.Editor = ds.Tables[0].Rows[0]["Editor"].ToString();
                if (ds.Tables[0].Rows[0]["EditTime"].ToString() != "")
                {
                    model.EditTime = DateTime.Parse(ds.Tables[0].Rows[0]["EditTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DispOrder"].ToString() != "")
                {
                    model.DispOrder = int.Parse(ds.Tables[0].Rows[0]["DispOrder"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ValidMark"].ToString() != "")
                {
                    model.ValidMark = int.Parse(ds.Tables[0].Rows[0]["ValidMark"].ToString());
                }
                model.Spare1 = ds.Tables[0].Rows[0]["Spare1"].ToString();
                model.Spare2 = ds.Tables[0].Rows[0]["Spare2"].ToString();
                model.Spare3 = ds.Tables[0].Rows[0]["Spare3"].ToString();
                model.Spare4 = ds.Tables[0].Rows[0]["Spare4"].ToString();
                if (ds.Tables[0].Rows[0]["SpareDecimal5"].ToString() != "")
                {
                    model.SpareDecimal5 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal5"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal6"].ToString() != "")
                {
                    model.SpareDecimal6 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal6"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal7"].ToString() != "")
                {
                    model.SpareDecimal7 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal7"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpareDecimal8"].ToString() != "")
                {
                    model.SpareDecimal8 = decimal.Parse(ds.Tables[0].Rows[0]["SpareDecimal8"].ToString());
                }

                if (ds.Tables[0].Rows[0]["CurrentPara"].ToString() != "")
                {
                    model.CurrentPara = (ds.Tables[0].Rows[0]["CurrentPara"].ToString()=="1" );
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strSqlString)
        {
            return DbHelperSQL.Query(strSqlString);
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" ExamSysParaID,SumScore,ExamTime,ExamTimes,QuestionsTotal,PassScore,ExamDescription,ExamType,Creator,ExamStartDate,ExamFinishDate,CreateTime,Editor,EditTime,DispOrder,ValidMark,Spare1,Spare2,Spare3,Spare4,SpareDecimal5,SpareDecimal6,SpareDecimal7,SpareDecimal8,CurrentPara ");
            strSql.Append(" FROM ExamSysPara ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "ExamSysPara";
            parameters[1].Value = "ExamSysParaID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method
    }
}

